<template>
	<view class="mineBox">
		<view class="navBox">
			<image src="/static/pages/index/bgImg.png" class="bgImg" mode=""></image>
			<view class="navBox1">
				<view class="title">
					我的
				</view>
				<view class="" @click="tologin">
					<view class="navImg">
						<image :src="avatar" class="tx" mode=""></image>
						<!-- <image src="../../../static/pages/index/img_aviter.png" mode=""></image> -->
					</view>
					<view class="nickName">
						{{nickname}}
					</view>
					
				</view>
				
			</view>
		</view>
		<!-- 数据 -->
		<view class="dataBox">
			<view class="dataNav">

				<!-- <view class="dataBox1" @click="jumpClick(1)">
					<view class="dataBox1Num">
						{{contentList.customer}}
					</view>
					<view class="dataBox1W">
						店铺数据
					</view>
				</view> -->
				<view class="dataBox1" @click="dianpuClick">
					<view class="dataBox1Num">
						{{contentList.sale}}
					</view>
					<view class="dataBox1W">
						店铺数据
					</view>
				</view>

			</view>

			<view class="dataContent">

				<view class="dataBox1" @click="jumpClick(3)">
					<view class="dataBox1Num">
						<image src="/static/pages/index/registration.png" class="registration" mode=""></image>
					</view>
					<view class="dataBox1W">
						活动信息
					</view>
				</view>

				<view class="dataBox1" @click="jumpClick(4)">
					<view class="dataBox1Num">
						<image src="/static/pages/index/icon_change_password.png" class="registration" mode=""></image>
					</view>
					<view class="dataBox1W">
						修改登录密码
					</view>
				</view>

			</view>
			<view class="dataContent1">

				<view class="dataBox1" @click="jumpClick(5)">
					<view class="dataBox1Num">
						<image src="/static/pages/index/icon_bindingwechat.png" class="registration" mode=""></image>
					</view>
					<view class="dataBox1W">
						绑定微信号
					</view>
				</view>

				<view class="dataBox1" @click="jumpClick(6)">
					<view class="dataBox1Num">
						<image src="/static/pages/index/icon_setup.png" class="registration" mode=""></image>
					</view>
					<view class="dataBox1W">
						设置
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		Statistics,
		wechatbind
	} from '@/request/api.js'
	export default {

		data() {
			return {
				avatar: '',
				nickname: '',
				contentList: {},
			};
		},
		onLoad() {
			if(uni.getStorageSync("login").avatar){
				this.avatar = 'https://dy.nuofenggr.com/' + uni.getStorageSync("login").avatar
				this.nickname = uni.getStorageSync("login").nickname
			}else{
				this.avatar  = '../../../static/pages/index/img_aviter.png'
				this.nickname  =  '未登录'
			}
			// this.avatar = 'https://dy.nuofenggr.com/' + uni.getStorageSync("login").avatar
			// this.nickname = uni.getStorageSync("login").nickname
			this.onlodeList()
		},
		onShow() {

		},
		methods: {
			// 点击未登录头像和字跳转到去登录
			tologin(){
				if(!uni.getStorageSync('login'))
				uni.navigateTo({
					url:'../../index/choice'
				})
			},
			onlodeList() {
				Statistics({
					type: uni.getStorageSync("login").type,
					user_id: uni.getStorageSync("login").id,
				}).then(res => {
					console.log(res);
					this.contentList = res.data
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
				})
			},
			dianpuClick(){
				uni.switchTab({
					url:'/pages/DLR/dataManagement/dataManagement'
				})
			},
			jumpClick(type) {
				// type=1 =>客户数据页面 
				// type=2 =>销售数据页面
				// type=3 =>活动信息
				// type=4 =>修改登录密码
				// type=5 =>绑定微信号
				// type=6 =>设置
				if (type == 1) {
					uni.navigateTo({
						url: '/pagesA/DLR/customerData?id=1'
					})
				}
				if (type == 2) {
					uni.navigateTo({
						url: '/pagesA/DLR/salesData?id=2'
					})
				}
				if (type == 3) {
					uni.navigateTo({
						url: '/pagesA/DLR/activityInformation'
					})
				}
				if (type == 4) {
					uni.navigateTo({
						url: '/pagesA/DLR/changePassword'
					})
				}
				if (type == 5) {  //绑定微信号
					wx.getUserProfile({
						desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
						success: infoRes => {
							wx.login({
								success(res) {
									console.log(res.code,'11111111111111')
									let data = {
										code:res.code,
										apptype:'miniapp',
										user_type:'2',
										user_id:uni.getStorageSync('login').id
									}
									wechatbind(data).then(ress=>{
										console.log(ress)
										if(ress.code==1){
											uni.showToast({
												title:ress.msg,
												icon:"none"
											})
										}else{
											uni.showToast({
												title:ress.msg,
												icon:"none"
											})
										}
									})
								}
							});
						}
					});
				}
				if (type == 6) {
					uni.navigateTo({
						url: '/pagesA/DLR/setUp'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.mineBox {
		width: 100%;
		box-sizing: border-box;
		padding-bottom: 40rpx;

		.navBox {
			width: 100%;
			height: 400rpx;
			position: relative;

			.bgImg {
				width: 100%;
				height: 100%;
			}

			.navBox1 {
				width: 100%;
				height: 100%;
				position: absolute;
				// top: calc(var(--status-bar-height) + 10rpx);
				top: 0;
				left: 0;
				overflow: hidden;

				.title {
					width: 100%;
					font-size: 40rpx;
					font-family: PingFang SC;
					font-weight: 500;
					text-align: center;
					margin-top: calc(var(--status-bar-height) + 20rpx);
					color: #FFFFFF;
				}

				.navImg {
					width: 100%;
					display: flex;
					justify-content: space-around;
					margin-top: 55rpx;

					.tx {
						width: 100rpx;
						height: 100rpx;
						border-radius: 50%;
					}
				}

				.nickName {
					font-size: 36rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #FEFEFE;
					text-align: center;
					margin-top: 24rpx;
				}
			}
		}

		.dataBox {
			width: 670rpx;
			// height: 200rpx;
			background-color: #FFFFFF;
			margin: -50rpx auto 0;
			position: relative;
			z-index: 99;
			box-shadow: 0px 4rpx 6rpx 0rpx rgba(218, 219, 222, 0.3);
			border-radius: 16rpx;

			.dataNav {
				width: 100%;
				display: flex;
				justify-content: space-around;

				.dataBox1 {
					width: 50%;
					overflow: hidden;

					.dataBox1Num {
						font-size: 48rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #303133;
						margin-top: 54rpx;
						text-align: center;
					}

					.dataBox1W {
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #303133;
						margin-top: 36rpx;
						text-align: center;
					}
				}
			}

			.dataContent {
				width: 100%;
				display: flex;
				justify-content: space-around;
				margin-top: 156rpx;

				.dataBox1 {
					width: 50%;
					overflow: hidden;

					.dataBox1Num {
						width: 68rpx;
						height: 68rpx;
						margin: 0 auto;

						.registration {
							width: 100%;
							height: 100%;
						}
					}

					.dataBox1W {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #303133;
						margin-top: 31rpx;
						text-align: center;
					}
				}
			}

			.dataContent1 {
				width: 100%;
				display: flex;
				justify-content: space-around;
				margin-top: 213rpx;

				.dataBox1 {
					overflow: hidden;
					width: 50%;

					.dataBox1Num {
						width: 68rpx;
						height: 68rpx;
						margin: 0 auto;

						.registration {
							width: 100%;
							height: 100%;
						}
					}

					.dataBox1W {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #303133;
						margin-top: 31rpx;
						text-align: center;
					}
				}
			}

		}
	}
</style>
